<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>选股宝扫雷</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">	
			p {margin:1px;}					
			ul {margin:1px;}			
			b {margin:0px}	
			.fixedBox{
				border: 5px solid #555555;
				white-space: nowrap;	
			}
			.fixedBox::-webkit-scrollbar {
				width: 10px;     
				height: 10px;				
			}
			
			#f10{
				color: #FFD700;		<!-- 公司概况、大事提醒 标题颜色-->
			}
			
			#f11{
				color: #FFFFE0;		<!-- 公司概况、大事提醒 详情颜色-->
			}
			
			#title{
				color: #FFFF00;		<!-- 标题颜色 -->
			}  
			
		</style>		
				
	</head>
	<body>
		
		<div id="towrite" class="fixedBox"></div>
		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		
		<script>
			window.onload = function() {						
				getSource();				
				changeStyle();					
			}
			
			function replaceDoc() {
				var url = encodeURI("http://www.treeid/dlglocalurl##homepath##company/选股宝扫雷.html##xxxxxx####STOCKNAME##");					
				window.location.replace(url)				
			}
			
			$(function() {
				setInterval(function() {
					if(isMinStatus()==false && ds == 1){			
						replaceDoc();										
					}					
				},
				500);
			})			
			
			//最小化
			function isMinStatus() {
			  var isMin = false;
			  if (window.outerWidth != undefined) {
				 isMin = window.outerWidth <= 160 && window.outerHeight <= 27;
			  } else {
				 isMin = window.screenTop < -30000 && window.screenLeft < -30000;
			  }
			 
				 return isMin;
			}			
			
			function changeStyle() {				
				var obj = document.getElementById("towrite");
				//obj.style.border = "none"; 
				obj.style.left= "0px"; 				
				obj.style.width= "90%";						
				//obj.style.height= "630px";		
				obj.style.fontSize="12px";									
			}			
			
		
			var gpdm = "";
			var gpmc = "";
			var dm = "";
			var ds = 0;
			var dms = "";
			function getSource() {
				var u = decodeURI(window.location.href);					
				if(u.indexOf("##") > -1){
					var gp = u.split('##');				
					dm = gp[1];
					gpmc = gp[2];					
					//alert(dm);
					dm == gpdm ? ds = 0: ds = 1;					
				}else{
					dm = "600000";
					gpmc = "浦发银行";
				}
				
				if(dm != gpdm){					
					gpdm = dm;
									
					if(dm.substr(0,1)=="6"){
						dms = dm + ".SS";					
					}else{
						dms = dm + ".SZ";					
					}
					
					//扫雷					
					var url32 = "https://api-ddc-wscn.xuangubao.cn/extract/stock_risk/full_desc?stock_code=" + dms; 																														
					xmlHttp32 = new XMLHttpRequest();							
					xmlHttp32.onreadystatechange = writeSource6;
					xmlHttp32.open("GET", url32, true);
					xmlHttp32.send(null);
					
				}
			}
						
			function writeSource6() { 
				if (xmlHttp32.readyState == 4) { 
					var div = document.getElementById('towrite'); 
					//div.innerHTML = "<b id=title>扫雷：</b>";
					//div.innerHTML = "<a href='javascript:void(0)' id='title' onclick='showInform(" + "\"towrite32\"" + ")'>扫雷</a>";
					div.innerHTML = "<font size='3' style=color:#FFFF00;>扫雷：<font size='2' color=#fff>&nbsp;&nbsp;&nbsp;&nbsp;" + gpdm + "&nbsp;&nbsp;" + gpmc + "</font></font>";

					var data = xmlHttp32.responseText;
					//document.write(data);
					data = data.replace(/ /g,"")														
					//data = data.match(/"data":(\S*)/)[1];
					
					var transform_aa = [                         		
						{"tag":"ul", children:function(){return(json2html.transform(this.data, transform_bb));}}			
					]; 
					
					var transform_bb = [ 
						{"tag": "ul style=color:#00FFFF;",children:[ 							
						{"tag": "b", "html":"安全项：" + "${safe_count}" + "&nbsp;&nbsp;&nbsp;危险项：" + "${risk_count}"},			
						{"tag":"ul style=color:#FFD700;", children:function(){return(json2html.transform(this.items, transform_cc));}}]}
					];  
					
					var transform_cc =             
						{"tag":"li", children:[                  						
						{"tag": "p", "html": function(){	
						var stars = this.stars;
						if(stars == 0){
							return("<span id=f10>" + this.risk_name + '：' + "<span id=f11>" + this.title);	
						}else{
							return("<span style=color:#FF4500;>" + this.risk_name + '：' + "<span style=color:#ADFF2F;>" + this.title);
						}												
					}},				
					]};
					
					var html = json2html.transform(data, transform_aa);
					div.innerHTML += html;	
					div.scrollTop = 0; //回到顶部	
				}
			}
		</script>
		
</html>